package demo.bocweb.login_module.activity;

import android.support.annotation.NonNull;

import com.alibaba.android.arouter.facade.annotation.Route;

import demo.bocweb.com.sdk.base.BasePresenter;
import demo.bocweb.com.sdk.base.activity.BaseMVPActivity;
import demo.bocweb.com.sdk.baseApi.RequestHelper;
import demo.bocweb.com.sdk.config.ARoutConfig;
import demo.bocweb.com.sdk.util.Loading;
import demo.bocweb.com.sdk.util.ToastyUtil;
import demo.bocweb.login_module.contract.ResetPhoneContract;
import demo.bocweb.login_module.presenter.ResetPhonePresenter;
import demo.bocweb.user_module.R;

/**
 * 修改手机号
 * Created by zhelun on 2018/2/3.
 */
@Route(path = ARoutConfig.resetPhonePath)
public class ResetPhoneActivity extends BaseMVPActivity<ResetPhoneContract.IResetPhonePresenter, ResetPhoneContract.IResetPhoneModel> implements ResetPhoneContract.IResetPhoneView {
    @NonNull
    @Override
    public BasePresenter initPresenter() {
        return new ResetPhonePresenter();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_find_phone;
    }

    @Override
    public void sendSmaCode() {
        Loading.show(this, getString(R.string.str_loading));
        mPresenter.sendSmaCode(RequestHelper.build()
                .add("Phone", "")
                .add("Type", 2)
                .create());
    }

    @Override
    public void sendSmaCodeSuccess() {

    }

    @Override
    public void checkSmaCode() {
        Loading.show(this, getString(R.string.str_loading));
        mPresenter.checkSmaCode(RequestHelper.build()
                .add("Phone", "")
                .add("Sms", "")
                .add("Type", 2)
                .create());
    }

    @Override
    public void checkSmaCodeSuccess() {
        resetPhone();
    }

    @Override
    public void resetPhone() {
        Loading.show(this, getString(R.string.str_loading));
        mPresenter.resetPhone(RequestHelper.build()
                .add("Phone", "")
                .add("NewPhone", "")
                .add("NewSmsCode", "")
                .create());
    }

    @Override
    public void resetPhoneSuccess() {
        ToastyUtil.showSuccess("修改手机号成功");
        finish();
    }
}
